#include"process.h"
#include<string.h>
#include<unistd.h>

#define NUM 101
#define STYLE '#'

const char*lable="|/-\\";
void FlushProcess(double total,double current)
{
    char buffer[NUM];
    memset(buffer,0,sizeof(buffer));
    int len=strlen(lable);

    static int cnt=0;

    int num=(int)(current*100/total); 
    int i=0;
    for(;i<num;i++)
    {
        buffer[i]=STYLE;
    }

    double rate=current/total;
    cnt %=len;
    //%-100s左对齐，预留100个字符空间
    printf("[%-100s][%.lf%%][%c]\r",buffer,rate*100,lable[cnt]);
    cnt++;
    fflush(stdout);
}